from django.template import Library

register = Library()

@register.simple_tag
def format_used_space(used_space):
    used_space = int(used_space)
    if (used_space < 1024*1024):
        return str(round(used_space/1024,2)) + ' KB'
    elif (used_space < 1024*1024*1024):
        return str(round(used_space/1024/1024,2)) + ' MB'
    else:
        return str(round(used_space/1024/1024/1024,2)) + ' GB'           
      
